package com.spzx.user.api.fallback;

import com.spzx.common.core.domain.R;
import com.spzx.common.core.exception.ServiceException;
import com.spzx.user.api.UserInfoFeignClient;
import com.spzx.user.api.domain.UpdateUserLogin;
import com.spzx.user.api.domain.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @ClassName UserInfoFeignClientFallbackFactory
 * @Author 波
 * @Date 2024/8/9 20:19
 */
@Slf4j
public class UserInfoFeignClientFallbackFactory implements FallbackFactory<UserInfoFeignClient> {
    @Override
    public UserInfoFeignClient create(Throwable cause) {
        return new UserInfoFeignClient() {
            @Override
            public R<Boolean> register(UserInfo userInfo, String source) {
                log.error("会员注册失败:"+cause.getMessage());
                return R.fail("会员注册失败:" + cause.getMessage());
            }

            @Override
            public R<Boolean> updateUserLogin(UpdateUserLogin updateUserLogin, String source) {
                log.error("更新登录信息失败:"+cause.getMessage());
                return R.fail("更新登录信息失败:" + cause.getMessage());
            }

            @Override
            public R<UserInfo> getUserInfo(String username, String source) {
                log.error("根据用户名获取会员信息失败:"+cause.getMessage());
                return R.fail("根据用户名获取会员信息失败:" + cause.getMessage());
            }
        };
    }
}
